<?php

if( isset($title) )
	echo "<h1>"
		. $title
		. (isset($header_after)?' '.$header_after:'')
		. ((isset($noadd)&&!$noadd) ? ' <a class="ibutton add" href="add/" title="'.__('Add').'"> </a>' : '')
		. "</h1>";

echo $this->display_flash();
echo $this->block('::before');
echo isset($out)&&!empty($out) ? $out : '';

if( isset( $assets ) && is_array( $assets ) )
	foreach( array( 'js', 'css' ) as $assets_type )
		if( isset( $assets[$assets_type] ) )
			assets::instance( ) ->$assets_type( @$assets[$assets_type] );

if( isset( $filter ) ) {
echo '<div class="form-filter">';
if( is_array( $filter ) )
	echo $this ->smarty_function( '_filter', $filter );
elseif( is_object( $filter ) )
	echo $filter ->display( );
else
	echo $filter;
echo '</div>';
}


if( isset( $pager ) ) {
	$pager_out = '';
	if( $pager->get_total_pages() > 1 ) {
		$pager_out = "<div id='pager'>" . $pager->display() . "</div>";
	}
	
	echo $pager_out;
}

if( isset( $items ) && count( $items ) )
{
	$cols = isset( $cols ) ? $cols : null;

	echo $this ->smarty_function( '_table', array( 'from' => $items, 'cols' => $cols, 'class' => isset($class) ? $class : 'plainlist', 'grouping' => @$grouping, 'table_row_handler' => @$table_row_handler, 'table_row_class' => @$table_row_class ) );
	$left = count( $items ) - $count;
	if( $left > 0 )
		echo sprintf(
			'<p>Кроме выведенных в базе есть еще %d %s...</p>',
			$left,
			_::plural( array( 'запись', 'записи', 'записей' ), $left )
			);
}
else
{
	echo "<p>" . __('List empty') . "</p>";
}


if( isset( $pager ) )
	echo $pager_out;

echo $this->block('::after');
